<?php
//
//defined('IN_IA') or exit('Access Denied');
//wl_load()->model('activity');
//wl_load()->func('message');
//
//$times = pdo_fetchall("select * from " .tablename('tg_times') ." where status = 1 ");
//foreach ($times as &$val) {
//    $title = "活动参加提醒";
//    $remark = "超过" .$val['blacktime'] ."次未参加就会加入黑名单哦！！！";
//    $time = TIMESTAMP + $val['activity_before'] * 60 * 60;
//    $collect1 = pdo_fetchall("select * from " .tablename('tg_collect')
//        ." where uniacid = '{$val['uniacid']}' and starttime < '{$time}' and active_before = 0 and orderno is not null limit 0,5 ");
//
//    foreach ($collect1 as &$value1) {
//        $order = pdo_fetch("select * from " .tablename('tg_order') ." where orderno = '{$value1['orderno']}'");
//        if ($order['status'] == 8){
//            $message = "您预约的 " .$value1['goodsname'] ." 项目还有" .$val['activity_before']
//                ."小时就要开始了，请于" .date('Y-m-d h:i' , $value1['starttime'])
//                ."准时参加，如不能准时参加，请在项目开始前" .$val['activity'] ."小时取消订单!";
//
//            $url = app_url('order/order/detail' , array('id' => $order['id']));
//            result_type($value1['openid'],$title,$message,$remark,$url);
//        }
//        pdo_update('tg_collect' , array('active_before' => 1) , array('orderno' => $value1['orderno']));
//    }
//
//
//    $title = "活动未到提醒";
////    $remark = "超过" .$val['blacktime'] ."次未参加就会加入黑名单哦！！！";
//    $time = TIMESTAMP - $val['activity_after'] * 60 * 60;
//
//    $collect = pdo_fetchall("select * from " .tablename('tg_collect')
//        ." where uniacid = '{$val['uniacid']}' and endtime < '{$time}' and active_after = 0 and orderno is not null limit 0,5 ");
//
//
//    foreach ($collect as &$value) {
//        $order = pdo_fetch("select * from " .tablename('tg_order') ." where orderno = '{$value['orderno']}'");
//
//        if ($order['status'] == 8) {
//            $message = "您预约的 " . $value['goodsname'] . " 项目没有参加!";
//
//            $url = app_url('order/order/detail', array('id' => $order['id']));
//            result_type($value['openid'], $title, $message, $remark, $url);
//        }
//        pdo_update('tg_collect' , array('active_after' => 1) , array('orderno' => $value['orderno']));
//    }
//
//    //TODO 创建日志
//    $path = TG_DATA."/log/".$val['uniacid']."/active/";
//    //首先判断目录存在否
//    if (!is_dir($path)){
//        //第3个参数“true”意思是能创建多级目录，iconv防止中文目录乱码
//        $res = mkdir(iconv("UTF-8", "GBK", $path), 0777, true);
//    }
//    $date = date('Y-m-d' , TIMESTAMP);
//    file_put_contents($path.$date.".log", var_export(
//            array(
//                'ip' => CLIENT_IP ,
//                'uniacid' => $val['uniacid'] ,
//                'filepath' => __FILE__ ,
//                'line' => __LINE__ ,
//                'time' => date('Y-m-d H:i:s' , TIMESTAMP)
//            ),
//            true) .PHP_EOL, FILE_APPEND);
//
//}
//
//exit();